<?php
/**
 * CLASS:Manager_interface
 * -------------------------------------------------------------------------------------------
 * FUNCTION: the common marnager interface 
 * ------------------------------------------------------------------------------------------
 * VERSION:1.0.0.0
 * ------------------------------------------------------------------------------------------
 * DATE:2013-12-02
 * -------------------------------------------------------------------------------------------
 * AUTHER: coderframer@gmail.com
 * -------------------------------------------------------------------------------------------
 * COPYRIGHT:www.pup6.net
 * -------------------------------------------------------------------------------------------
 * */
class Manager_interface extends CI_Model {
	public function __construct() {
		parent::__construct();
		//loading the comm model file
		$this->load->model('Comm');
	}
   /**
    * login the admin public function
    * @access public
    * @param null
    * @return  the result is  yes it will  return an array about the userinfo ,or empty it will return 0 
    * */
	public function getAdmin() {
		$email = $this->input->post('email');
		$passwd = $this->input->post('password');
		/*Throungh the value of the configuration array encryption*/
		$passwd = md5(md5($passwd).$this->config->item('admin_key'));
		$arrResult = $this->Comm->getList('manager', 'aid, email, passwd, nick_name, powers', array('email'=>$email,'passwd'=>$passwd));
		if(isset($arrResult[0]['aid']) && $arrResult[0]['aid'] > 0) {
			return $arrResult[0];
		}
		return 0;
	}
	/**
	 * get the class channer function
	 * @access public
	 * @param $arrWhere the where array the key with the value
	 * @return return the array result 
	 * */
	public function getChannel($arrWhere = NULL) {
		return $this->Comm->getList('channel', 'cid, channel, title, en_title, parent, depth, orders', $arrWhere, NULL,
			array('orderBy'=>'channel asc, orders asc'));
	}
	/**
	 * change the class channer order function
	 * @access public
	 * @param $arrWhere the where array the key with the value
	 * @return void
	 * */
	public function updateChannelOrder($where) {
		$this->db->where($where);
		$this->db->set('orders', 'orders+1', FALSE);
		$this->db->update('channel');
	}
	
}